<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<!-- header -->
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <div class="header">
        <div class="head-back">
            <a href="javascript:void(0);" tapmode onclick="comeBack()" class="back-btn"></a>
        </div>
        <div class="head-title">
            <h6>相关新闻</h6>
        </div>
        <!--<div class="head-action">
            <a href="javascript:void(0);" tapmode onclick="openModel()" class="action-btn"></a>
        </div>-->
    </div>
</div>
<!-- header end -->
<div id="mescroll" class="mescroll" style="padding-top: 1.4rem;">
    <div class="school-section">

        <div class="section">
            <div class="index-news" style="padding: 0 0.3rem;">
                <ul id="newsContent">
                    <!--<li>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</li>-->
                </ul>
            </div>
        </div>

    </div>
</div>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    var tips_id = '';//新闻标签id
    var page = 1;
    var pullUp = false;
    apiready = function () {

        setFixStatusBar(); //设置状态栏
        keybackListener()
        tips_id = api.pageParam.tips_id;
        console.log("tips_id:"+tips_id)

        /*pullUpLoading(function () {
            if(pullUp == true){
                getNewsList()
            }
        });*/

        /*//下拉刷新
        dropDownRefresh(function () {
            page = 1;
            getNewsList()
        });*/

        getNewsList();

        SystemCheckVersion()

    };

    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        },
        up: {
            auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
            isBounce: false, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10
            callback: upCallback, //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
            /*toTop:{ //配置回到顶部按钮
                src : "../res/img/mescroll-totop.png", //默认滚动到1000px显示,可配置offset修改
                //offset : 1000
            }*/
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        page = 1;
        getNewsList()

        //mescroll.endErr();
    }
    /*上拉加载的回调 */
    function upCallback() {
        if (pullUp == true) {
            getNewsList()
        }else {
            mescroll.endErr();
        }
    }

    //
    function aboutNews(id) {
        tips_id = id
        page = 1;
        $('.mescroll').animate({scrollTop:0},0);
        getNewsList()
    }


    //活动详情
    function getNewsList() {

        var param = {
            token: $api.getStorage('token'),
            label_id: tips_id,
            page: page,
        }
        getAjax(Interface.news_lists, param, function (res) {
            console.log(jsonChange(res))
            pullUp = false;
            var data = res.data;
            if (isDefine(data)) {
                var listHtml = '';
                for (var i = 0; i < data.length; i++) {
                    var listData = data[i].data;
                    var toUp = '';
                    var hotHtml = '';
                    if (isDefine(listData)) {
                        if (listData.recommend == 1) {
                            // toUp = '<span class="bt-pd toUp">置顶</span>';
                        }

                        var news_label = '';
                        if(isDefine(listData.news_label_name)){
                            $.each(listData.news_label_name,function (k,ktem) {
                                if(k<2){
                                    news_label +='<span class="bt-pd tips" onclick=\'aboutNews(' + ktem.id + ')\'>#' + ktem.title + '#</span>';
                                }
                            })
                        }
                        hotHtml = '<div class="detail-bottom">' +
                            '              <div class="bottom-tips">' + toUp + news_label +
                            // '                  <span class="bt-pd time">' + listData.date + '</span>' +
                            '              </div>' +
                            '              <div class="bottom-hot">' + listData.hot_number + '</div>' +
                            '          </div>';

                    }
                    //标题，文字，图片
                    var param;
                    var url;
                    if(isDefine(listData.url)){
                        param = {"url": listData.url,"news_id": listData.id};
                        url = '../index/banner_detail';
                    }else {
                        param = {"news_id": listData.id};
                        url = "../index/news_detail";
                    }

                    var titleHtml = '';
                    if (isDefine(listData.void_ids)) {
                        // var video_path = getVideoPic(ajaxUrl + listData.void_ids);
                        var video_path = '';
                        //视频新闻
                        titleHtml = '<div class="video-detail">' +
                            '             <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' + listData.title + '</h6>' +
                            '             <div class="video-box bg-cover" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\' style="background-image: url(' + ajaxUrl + listData.void_icon_path + ')";>' +
                            '                 <p class="single-ellipsis"></p>' +
                            '                 <span class="icon-play"></span>' +
                            '                 <span class="time"></span>' +
                            '              </div>' + hotHtml +
                            '         </div>';

                    } else {
                        //三张图片新闻
                        if (isDefine(listData.icon_path)) {
                            if (listData.icon_path.length >= 3) {
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' + listData.title + '</h6>' +
                                    '            <div class="detail-img-list" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[1] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[2] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (listData.icon_path.length == 2) {
                                //两张图片新闻
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' + listData.title + '</h6>' +
                                    '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[1] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (listData.icon_path.length == 1) {

                                news_label = '';
                                if(isDefine(listData.news_label_name)){
                                    $.each(listData.news_label_name,function (k,ktem) {
                                        if(k<2){
                                            news_label +='<span class="bt-pd tips" onclick=\'aboutNews(' + ktem.id + ')\'>#' + ktem.title + '#</span>';
                                        }
                                    })
                                }
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp + news_label +
                                    // '                  <span class="bt-pd time">' + listData.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + listData.hot_number + '</div>' +
                                    '          </div>';

                                //单张图片新闻
                                titleHtml = '<div class="single-news">' +
                                    '             <div class="detail-img-list" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' +
                                    '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icon_path[0] + ');"></div>' +
                                    '             </div>' +
                                    '             <div class="video-detail">' +
                                    '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ',1)\'>' + listData.title + '</h6>'  + hotHtml +
                                    // '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("news_detail",' + jsonChange(param) + ')\'>' + listData.brief + '</p>' + hotHtml +
                                    '             </div>' +
                                    '         </div>';
                            }

                        }

                    }

                    listHtml += '<li>' + titleHtml + '</li>'

                }
                if(page == 1){
                    $('#newsContent').html(listHtml);

                }else {
                    $('#newsContent').append(listHtml);
                }
                page ++ ;
                pullUp = true

            }else {
                if(page == 1){
                    $('#newsContent').html(noData);

                }else {
                    $('#newsContent').append('<p class="t-c c-999 pt30 pb30 f24">没有更多了</p>');
                }
                pullUp = false
            }

            mescroll.endErr()
            pop.close();
        }, function (error) {
            $('#newsContent').html(noData);
            pop.notice(error.msg)
            pop.close();
            mescroll.endErr()
            pullUp = false
        })
    }


</script>
